#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include"game.h"
void menu()
{
	printf("********************************\n");
	printf("***1->玩游戏******0->退出游戏***\n");
	printf("********************************\n");
}
void game()
{
	char board[ROW][COL] = { 0 };
	InitBoard(board,ROW,COL);
	DisplayBoard(board, ROW, COL);
	char ret = 0;
	while (1)
	{
		PlayerMove(board, ROW, COL);
		DisplayBoard(board, ROW, COL);
		ret = IsWin(board, ROW, COL);
		if (ret != 'c')
		{
			break;
		}
		ComputerMove(board, ROW, COL);
		DisplayBoard(board, ROW, COL);
		ret = IsWin(board, ROW, COL);
		if (ret != 'c')
		{
			break;
		}
	} 
	if (ret == '*')
	{
		printf("你赢了\n");
	}
	if (ret == '#')
	{
		printf("电脑赢了\n");
	}
	if(ret =='Q')
	{
		printf("平局\n");
	}


}
int main()
{
	srand((unsigned int) time(NULL));
	int input = 0;
	do
	{
		menu();
		scanf("%d", &input);
		switch (input)
		{
		case 1:
			game();
			break;
		case 0:
			printf("游戏已经退出\n");
		default:
			printf("选择错误，请重新选择\n");
			break;
		}
	} while (input);

	return 0;
}